import type { OrderResult, SubmitOrderParams } from '@/types/order'
import { http } from '@/utils/http'

// 获取预付订单
export const getOrderPreAPI = async () => {
  return http<OrderResult>({
    method: 'GET',
    url: '/member/order/pre',
  })
}

// 获取立即购买订单
export const getOrderProNowAPI = async (data: {
  skuId: string
  count: string
  addressId: string
}) => {
  return http<OrderResult>({
    method: 'GET',
    url: '/member/order/pre/now',
    data,
  })
}

//提交订单
export const getSubmitOrderAPI = async (data: SubmitOrderParams) => {
  return http<{ id: string }>({
    method: 'POST',
    url: '/member/order',
    data,
  })
}

// 获取订单详情
export const getOrderListAPI = async (id: string) => {
  return http({
    method: 'GET',
    url: `/member/order/${id}`,
  })
}

// 获取支付参数 *实际开发使用
export const getPayParamsAPI = async (id: string) => {
  return http({
    method: 'GET',
    url: `/pay/wxPay/miniPay`,
    data: { orderId: id },
  })
}

//模拟支付  * 开发阶段使用，直接改变支付状态为已支付
export const getMoniPayParamsAPI = async (id: string) => {
  return http({
    method: 'GET',
    url: `/pay/mock`,
    data: { orderId: id },
  })
}
